package com.pureut.system.service.impl;

import cn.hutool.core.bean.BeanUtil;
import com.baomidou.mybatisplus.extension.plugins.pagination.Page;
import com.pureut.common.security.utils.SecurityUtils;
import com.pureut.system.domain.MaterialScrapManagement;
import com.pureut.system.domain.vo.MaterialScrapManagementVo;
import com.pureut.system.mapper.MaterialScrapManagementMapper;
import com.pureut.system.service.IMaterialScrapManagementService;
import org.apache.catalina.security.SecurityUtil;
import org.springframework.stereotype.Service;
import java.util.Date;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.baomidou.mybatisplus.extension.service.impl.ServiceImpl;

import javax.annotation.Resource;

/**
 * @Author: pureut
 * @Date: 2025-04-08 13:41:29
 * @Desc: 物料报废管理表
 */
@Service("materialScrapManagementService")
public class MaterialScrapManagementServiceImpl extends ServiceImpl<MaterialScrapManagementMapper, MaterialScrapManagement> implements IMaterialScrapManagementService {

    /**
     * 物料报废管理表Dao
     */
    @Resource
    private MaterialScrapManagementMapper materialScrapManagementMapper;




    /**
     * 新增物料报废管理表
     * @param materialScrapManagementVo
     * @return
     */
    @Override
    public Boolean save(MaterialScrapManagementVo materialScrapManagementVo) {
        MaterialScrapManagement materialScrapManagement = new MaterialScrapManagement();
        BeanUtil.copyProperties(materialScrapManagementVo, materialScrapManagement);
        materialScrapManagement.setCreateBy(SecurityUtils.getUsername());
        materialScrapManagement.setCreateTime(new Date());
        return save(materialScrapManagement);
    }


    /**
     * 更新物料报废管理表
     * @param materialScrapManagementVo
     * @return
     */
    @Override
    public Boolean updateById(MaterialScrapManagementVo materialScrapManagementVo) {
        MaterialScrapManagement materialScrapManagement = new MaterialScrapManagement();
        BeanUtil.copyProperties(materialScrapManagementVo, materialScrapManagement);
        materialScrapManagement.setUpdateBy(SecurityUtils.getUsername());
        materialScrapManagement.setUpdateTime(new Date());
        return updateById(materialScrapManagement);
    }
}
